package com.jiang.jopo;

import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Arrays;
import java.util.Date;

/**
 * @author jiangjingbo
 * @version V1.0
 * @Project java2203
 * @Package com.jiang.jopo
 * @Description:
 * @Date 2022/6/7 19:55
 */
public class User {
//    //json转换的时候忽略
//    @JsonIgnore
//    private Integer id;
//    private String name;
//    //json转换的时候 将 gender 转化为 sex
//    @JsonProperty("sex")
//    private boolean gender;
//
//    @JsonInclude(JsonInclude.Include.NON_NULL)
//    private String [] array;
//    @DateTimeFormat(pattern = "yyyy-MM-dd")
//    @JsonFormat(pattern = "yyyy-MM-dd")
//    private Date birthday;

//    阿里fastjson注解
    //json转换的时候不显示
    @JSONField(serialize = false)
    private Integer id;
    private String name;
    //转换的时候转换为sex
    @JSONField(name = "sex")
    private boolean gender;

    private String [] array;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JSONField(format = "yyyy-MM-dd")
    private Date birthday;


    public User(Integer id, String name, boolean gender, String[] array) {
        this.id = id;
        this.name = name;
        this.gender = gender;
        this.array = array;
    }

    public User() {
    }

    public Integer getId() {

        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public String[] getArray() {
        return array;
    }

    public void setArray(String[] array) {
        this.array = array;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", array=" + Arrays.toString(array) +
                ", birthday=" + birthday +
                '}';
      }
}
